/***********************************************************************
** Copyright (C) GUOG. All rights reserved.
** Author			: wsr
** Date				: 2014.05.04
** Name				: boainterface.h
** Version			: 1.0
** Description			: 定义一些onvif模块需要用到的功能函数
** Modify Record		:
1:Creat on 2014.05.04

***********************************************************************/
#ifndef _BOA_INTERFACE_H_
#define _BOA_INTERFACE_H_

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <arpa/inet.h>          /* inet_ntoa */

#define MAX_NET_LEN	50
#define VIDEO_NAME_LEN	100
#define MAX_PRO 4
#define TRUE 1
#define FALSE 0
#define INFO_LENGTH 100
#define LARGE_INFO_LENGTH 1024
#define ONVIF_LISTEN_PORT 3702
#define ETH_NAME 	"eth1"
#define ETH_NAME_LOCAL	"eth1:avahi"
#define MID_INFO_LENGTH 40
#define SMALL_INFO_LENGTH 512
#define MACH_ADDR_LENGTH 6
#define MAX_PROF_TOKEN 200

#define BOA_VERSION	"1.0.0"
/*
typedef union __NET_IPV4 {
	unsigned int	int32;
	unsigned short	str[4];
} NET_IPV4;
*/
int netGetIp(char *pInterface, unsigned int *ip);

int netGetMac(char *pInterface, unsigned char *pMac);

in_addr_t net_get_ifaddr(char *ifname);
int net_get_hwaddr(char *ifname, unsigned char *mac);


/** net config */
typedef struct
{
	char IP[MAX_NET_LEN];
	char Mac[MAX_NET_LEN];
	char GateWay[MAX_NET_LEN];
	char Dns[MAX_NET_LEN];
}Net_Config_Data;

/**video source profile config*/
typedef struct
{
	char 	Vname[VIDEO_NAME_LEN];
	int 	Vcount;
	char 	Vtoken[VIDEO_NAME_LEN];
	char 	VsourceToken[VIDEO_NAME_LEN];
	int 	windowx;
	int 	windowy;
	int 	windowWidth;
	int 	windowHeight;
}Video_Source_Config_Data;

/** ntp param config*/
typedef struct
{
	char 			ntpServer[MAX_NET_LEN];
	unsigned long 	currentTime;
}Ntp_Config_Data;

/** dhcp status flag*/
typedef struct
{
	int DhcpFlag;
}Dhcp_Config_Data;

/** image param config*/
typedef struct
{
	float 	Brightness;
	float 	ColorSaturation;
	float 	Contrast;
	int 	BacklightCompenSationMod;
	float 	Sharpness;
	int 	WideDynamicMode;
	int 	WhiteBalanceMode;
	float 	BackLightLevel;
	float 	CrGain;
	float 	CbGain;
}Image_Config_Data;

typedef struct
{
	int 	nIPType;
	char 	IPv4Addr[MAX_NET_LEN];
	char 	IPv6Addr[MAX_NET_LEN];
	int 	port;
	int 	ttl;
	int 	autostart;
}Video_Multicast_Config_Data;

/** video encoder profile config*/
typedef struct
{
	char 						Vename[VIDEO_NAME_LEN];
	char 						Vetoken[VIDEO_NAME_LEN];
	char						rtsp[200];
	int 						VeuserCount;
	float 						Vequality;
	int 						Vencoder;//0-jpg 2-h264
	int 						Rwidth;
	int 						Rheight;
	int							bitratelimit;
	int 						frameratelimit;
	int 						encodinginterval;
	int 						Mpeggovlength;
	int 						Mpegprofile;
	int 						H264govlength;
	int 						H264profile;
	long 						sessiontimeout;
	Video_Multicast_Config_Data videoMulticastConfig;
}Video_Encoder_Config_Data;

/** PTZ profile config*/
typedef struct
{
	char Pname[VIDEO_NAME_LEN];
	char Ptoken[VIDEO_NAME_LEN];
	char PnodeToken[VIDEO_NAME_LEN];
}PTZ_Config_Data;

/** device info struct */
typedef struct
{
	char hostName[VIDEO_NAME_LEN];
	char manufacturer[VIDEO_NAME_LEN];
	char Model[VIDEO_NAME_LEN];
	char Hardware[VIDEO_NAME_LEN];
	char Firmware[VIDEO_NAME_LEN];
	char DeviceID[VIDEO_NAME_LEN];
}Device_Info_Data;

/** Protocols struct */
typedef struct
{
	int httpPort;
	int httpsPort;
	int rtspPort1;
	int rtspPort2;
	int rtspPort3;
	int rtspPort4;
}NetProto_Port_Data;

/** onvif profile config*/
typedef struct
{
	char 						profileName[VIDEO_NAME_LEN];
	char 						profileToken[VIDEO_NAME_LEN];
	Video_Source_Config_Data 	VSCD;
	Video_Encoder_Config_Data 	VECD;
}Onvif_Profile_Data;

typedef struct
{
	int 					nProfile;//nProfile 不可以超过MAX_PRO
	Onvif_Profile_Data 		Profile[MAX_PRO];
	Device_Info_Data 		DeviceInfo;
	PTZ_Config_Data			PtzProfile;
	Image_Config_Data		Image;
	Dhcp_Config_Data 		DHCP;
	Ntp_Config_Data 		NTP;
	Net_Config_Data 		NET;
	NetProto_Port_Data		NetProtoPort;
}Onvif_Config_Data;

/**
函数功能：初始化onvif参数中的固定不变的信息
		NET、NTP、DHCP、完全没有初始化
		Profile中的部分信息没有初始化
参数：onvifParam 是Onvif_Config_Data指针
返回值：无
*/
void OnvifParamInit(Onvif_Config_Data *onvifParam);

extern Onvif_Config_Data onvifConfig;

#endif
